<template>
  <div class="result">
    <div class="result_title">
      <p style="margin-right: 20px">研究科目</p>
    </div>
    <div class="result_table">
      <el-table :data="currentList" style="width: 100%">
        <el-table-column fixed prop="title" label="名称"> </el-table-column>
        <el-table-column prop="createdAt" label="创建日期" width="200">
        </el-table-column>
        <el-table-column prop="updatedAt" label="更新日期" width="200">
        </el-table-column>
        <el-table-column label="操作" width="100">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="result_pagination">
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page.sync="currentVal.page"
        :page-size="currentVal.size"
        layout="total, prev, pager, next"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { getResearchList } from "@/api/research";
export default {
  name: "result",
  data() {
    return {
      total: 0,
      currentVal: {
        page: 1,
        size: 10,
        data: {
          type: "result",
          keyword: "",
        },
      },
      currentList: [],
    };
  },
  mounted() {
    this.getResearchList(this.currentVal);
  },
  methods: {
    getResearchList(data) {
      getResearchList(data).then((response) => {
        if (response.data.code === 20000) {
          const { list, totalRecords } = response.data.results;
          this.total = totalRecords;
          this.currentList = list;
        }
      });
    },
    handleCurrentChange(val) {
      this.currentVal.page = val;
      this.getClassRoomList(this.roomVal);
    },
    handleClick(row) {
      console.log(row);
      this.$router.push({
        path: "/academicResearch/resultDetails",
        query: {
          currentId: row.id
        }
      });
    },
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.result {
  .result_title {
    height: 40px;
    background: #f1f1f1;
    text-align: right;
    line-height: 40px;
    font-weight: bold;
    font-size: 21px;
    color: #0a7b19;
  }
  .result_table {
    margin-top: 20px;
    margin-bottom: 50px;
    .el-button--text {
      color: #0a7b19;
    }
  }
  .result_pagination {
    width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    margin-bottom: 50px;
    .result_pagination_button {
      width: 86px;
      height: 38px;
      line-height: 38px;
      border: 1px solid #0a7b19;
      border-radius: 8px;
      color: #0a7b19;
      font-weight: bold;
      text-align: center;
      transition: all 0.2s linear;
      cursor: pointer;
      &:hover {
        background-color: #0a7b19;
        color: white;
      }
    }
  }
}
</style>
